local rolely_dangcheng = fk.CreateSkill {
    name = "rolely_dangcheng",
    tags = { Skill.Limited }
}
Fk:loadTranslationTable {
    ["rolely_dangcheng"] = "荡城",
    [":rolely_dangcheng"] = "限定技，当你受到其他角色造成的伤害后，若你的体力值不足体力上限的一半，你可以令一名角色从游戏外装备一张<a href=':dz_yuxi'>【玉玺】</a>，" ..
        "然后对所有角色造成一点火焰伤害，你回复因此造成伤害值等量的体力，立刻执行一个额外的回合。",

    ["#rolely_dangcheng-choose"] = "荡城：是否令一名角色装备【玉玺】，然后打所有人一巴掌(火伤)。",

    ["$rolely_dangcheng1"] = "天下事在我，谁敢不从！",
    ["$rolely_dangcheng2"] = "群枭伺动，为董作怅！",
}

local U = require "packages/utility/utility"
rolely_dangcheng:addEffect(fk.Damaged, {
    can_trigger = function(self, event, target, player, data)
        return target == player and player:hasSkill(rolely_dangcheng.name) and player.hp < (player.maxHp / 2) and
            not player.dead and data.from and data.from ~= player and
            player:usedSkillTimes(rolely_dangcheng.name, player.HistoryGame) == 0
    end,
    on_cost = function(self, event, target, player, data)
        local room = player.room
        local tos = room:askToChoosePlayers(player, {
            skill_name = rolely_dangcheng.name,
            min_num = 1,
            max_num = 1,
            targets = room:getOtherPlayers(player, false),
            prompt = "#rolely_dangcheng-choose",
            cancelable = true,
        })
        if #tos > 0 then
            event:setCostData(self, { tos = tos })
            return true
        end
    end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        local tos = event:getCostData(self).tos[1]
        local dz_yuxi = table.find(
            U.prepareDeriveCards(room, { { "dz_yuxi", Card.Heart, 8 } }, rolely_dangcheng.name),
            function(id)
                return player.room:getCardArea(id) == Card.Void
            end)
        if dz_yuxi then
            room:moveCardIntoEquip(tos, dz_yuxi, rolely_dangcheng.name, true, player)
        end
        for _, id in ipairs(room:getOtherPlayers(player)) do
            room:damage({
                from = player,
                to = id,
                damage = 1,
                damageType = fk.FireDamage,
                skillName = rolely_dangcheng.name
            })
        end
        data.from:endCurrentPhase()
        player:gainAnExtraTurn(false, rolely_dangcheng.name)
    end
})
rolely_dangcheng:addEffect(fk.Damage, {
    mute = true,
    can_trigger = function(self, event, target, player, data)
        return target == player and player:hasSkill(rolely_dangcheng.name) and data.from == player and
            data.skillName == "rolely_dangcheng"
    end,
    on_cost = Util.TrueFunc,
    on_use = function(self, event, target, player, data)
        player.room:recover {
            who = player,
            num = data.damage,
            recoverBy = player,
            skillName = rolely_dangcheng.name,
        }
    end
})
return rolely_dangcheng
